package com.xiaoyi.library.controller;

import com.xiaoyi.library.pojo.Record;
import com.xiaoyi.library.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class RecordController {
    private final RecordService recordService;

    @Autowired
    public RecordController(RecordService recordService) {
        this.recordService = recordService;
    }

    @RequestMapping("/loadingrecord")
    public List<Record> query() {
        List<Record> list = recordService.find();
        System.out.println(list);
        return list;
    }

    @GetMapping("/searchrecord")
    public List<Record> search(String record_bookname) {
        List<Record> list = recordService.findByName(record_bookname);
        System.out.println(list);
        return list;
    }
}
